import React from 'react';
import type {PaginationProps} from 'antd';
import {Pagination} from 'antd';

const showTotal: PaginationProps['showTotal'] = (total) => `共 ${total} 条`;

type OmitType = 'pageSize' | 'total'

type PropsType = {
    pageNo: number,
    onChange: Function
}

type Props = Pick<PaginationProps, OmitType> & PropsType

const Index: React.FC<Required<Props>> = ({total, pageNo, pageSize, onChange}) => {

    return <Pagination
        current={pageNo}
        pageSize={pageSize}
        total={total}
        onChange={(pn: number, ps: number) => onChange(pn, ps)}
        showTotal={showTotal}
        showSizeChanger
        showQuickJumper
        style={{ marginTop: 16, textAlign: 'right' }}
    />
}

export default React.memo(Index);
